package com.rc.evcharger.common.utils;

import java.math.BigDecimal;

import static com.rc.evcharger.common.utils.DataUtil.SPLIT;

/**
 * Create by Yang on 2021/11/6
 */
public class AplDataUtil {

    /**
     * 自动拼接
     *
     * @param value
     * @param isSplit
     * @return
     */
    public static BigDecimal getBigdecmlByBCDValue(String value, boolean isSplit, int rate) {
        if (isSplit) {
            return BigDecimal.ZERO;
        }
        String[] strs = value.split(SPLIT);
        StringBuffer sb = new StringBuffer();
        for (String str : strs) {
            sb.append(str);
        }

        BigDecimal bigDecimal = new BigDecimal(Integer.valueOf(sb.toString()));

        BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(Math.pow(10, 2))).setScale(rate);


        return bigDecimal1;
    }

    public static void main(String[] args) {
        BigDecimal bigdecmlByBCDValue = AplDataUtil.getBigdecmlByBCDValue("02 20", false, 2);
        System.out.println(bigdecmlByBCDValue);
    }
}
